package com.itheima.health.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.itheima.health.pojo.Member;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

public interface MemberMapper extends BaseMapper<Member> {

    @Select("select id,phonenumber from t_member where phonenumber=#{telephone}")
    Member findMemberByTelephone(@Param("telephone") String telephone);

    @Select("select name from t_member where id=#{memberId}")
    Member findMemberNameByMemberId(@Param("memberId") Integer memberId);


    //报表数据 todoby dzf
    @Select("select count(1) from t_member tm,rpt_date rd " +
            "where DATE_FORMAT(current_date,'%u') = rd.fweek " +
            "and tm.REGTIME = rd.fdate and DATE_FORMAT(current_date,'%Y') = rd.fyear")
    Integer getWeekNumber();

    @Select("select count(1) from t_member where REGTIME =current_date")
    Integer getDayNumber();

    @Select("select count(1) from t_member")
    Integer totalMember();


    @Select("select count(1) from t_member tm,rpt_date rd where DATE_FORMAT(current_date,'%m') = rd.fmonth " +
            "and tm.REGTIME = rd.fdate " +
            "and DATE_FORMAT(current_date,'%Y') = rd.fyear")
    Integer getMonthNumber();

}
